﻿using System;
using System.Data;
using System.Collections;
using System.Web.UI;
public partial class _Default : System.Web.UI.Page 
{
    Data data = new Data();
    protected void Page_Load(object sender, EventArgs e)
    {
        FillHTML();
        FillMenuTrai();
        
        FillYahoo();
    }

    private void FillYahoo()
    {
        string result = "";
        DataTable table = data.GetTable_By_Name("Yahoo");
        int count = table.Rows.Count;
        if (count > 5)
        {
            for (int i = 0; i < 5; i++)
            {
                result += " <LI style='PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BACKGROUND: none transparent scroll repeat 0% 0%; LEFT: -10px; PADDING-BOTTOM: 0px; BORDER-TOP-STYLE: none; PADDING-TOP: 0px; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; TOP: 55px; BORDER-BOTTOM-STYLE: none'>" +
                                 "<A style='PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BACKGROUND: none transparent scroll repeat 0% 0%; PADDING-BOTTOM: 0px; BORDER-TOP-STYLE: none; PADDING-TOP: 0px; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none' href='ymsgr:sendim?" + table.Rows[i]["YahooAddress"].ToString() + "' target=_self>" +
                                 "<SPAN style='COLOR: #fff; MARGIN-RIGHT: 0px'>" + table.Rows[i]["YahooName"].ToString() + "</SPAN>" +
                                 "<IMG style='DISPLAY: inline; MARGIN-LEFT: 0px; WIDTH: 79px' alt=popupmenu  src='../File/theme_images/yahoo_icon.png'></A>" +
                                 "</LI>";
            }
        }
        else
        {
            for (int i = 0; i < count; i++)
            {
                result += " <LI style='PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BACKGROUND: none transparent scroll repeat 0% 0%; LEFT: -10px; PADDING-BOTTOM: 0px; BORDER-TOP-STYLE: none; PADDING-TOP: 0px; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; TOP: 55px; BORDER-BOTTOM-STYLE: none'>" +
                                  "<A style='PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BACKGROUND: none transparent scroll repeat 0% 0%; PADDING-BOTTOM: 0px; BORDER-TOP-STYLE: none; PADDING-TOP: 0px; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none' href='ymsgr:sendim?" + table.Rows[i]["YahooAddress"].ToString() + "' target=_self>" +
                                  "<SPAN style='COLOR: #fff; MARGIN-RIGHT: 0px'>" + table.Rows[i]["YahooName"].ToString() + "</SPAN>" +
                                  "<IMG style='DISPLAY: inline; MARGIN-LEFT: 0px; WIDTH: 79px' alt=popupmenu  src='../File/theme_images/yahoo_icon.png'></A>" +
                                  "</LI>";
            }
        }
        ltlYahoo.Text = result;
    }

    private void FillMenuTrai()
    {
        string sourceMenuTrai = "<script type='text/javascript'>" + Environment.NewLine +
                                "function JSCook_menu_502e282f1438a_addEvent( obj, type, fn )"+ Environment.NewLine +
                                "{" + Environment.NewLine +
                                   "if (obj.addEventListener) {" + Environment.NewLine +
                                      "obj.addEventListener( type, fn, false );" + Environment.NewLine +
                                   "} else if (obj.attachEvent) {" + Environment.NewLine +
                                      "obj[\"e\"+type+fn] = fn;" + Environment.NewLine +
                                      "obj[type+fn] = function() { obj[\"e\"+type+fn]( window.event ); }" + Environment.NewLine +
                                      "obj.attachEvent( \"on\"+type, obj[type+fn] );" + Environment.NewLine +
                                   "}" + Environment.NewLine +
                                "}" + Environment.NewLine +
                                "function JSCook_menu_502e282f1438a_removeEvent( obj, type, fn )" + Environment.NewLine +
                                "{" + Environment.NewLine +
                                   "if (obj.removeEventListener) {" + Environment.NewLine +
                                      "obj.removeEventListener( type, fn, false );" + Environment.NewLine +
                                   "} else if (obj.detachEvent) {" + Environment.NewLine +
                                      "obj.detachEvent( \"on\"+type, obj[type+fn] );" + Environment.NewLine +
                                      "obj[type+fn] = null;" + Environment.NewLine +
                                      "obj[\"e\"+type+fn] = null;" + Environment.NewLine +
                                   "}" + Environment.NewLine +
                                "}" + Environment.NewLine +
                                "var JSCook_menu_502e282f1438a = " + Environment.NewLine +
                                "["  + Environment.NewLine ;

        ArrayList MenuParent = MenuTrai.MenuParent();
        bool checkParent=false;
        for (int i = 0; i < MenuParent.Count; i++)
        {
            if (data.CheckMenuParent(MenuParent[i].ToString().Split(';')[1])  == false )
            {
                sourceMenuTrai += "[ '<img src=\"../File/theme_images/iconmenumore.gif\" />','" + MenuParent[i].ToString().Split(';')[2] + "','../Tu-Van-Phap-Luat/Default.aspx?MucPhapLuatID=" + MenuParent[i].ToString().Split(';')[0] + "',null,'" + MenuParent[i].ToString().Split(';')[2] + "'" +
                                    Environment.NewLine + "]," + Environment.NewLine;
            }
            else
            {
                sourceMenuTrai += "[ '<img src=\"../File/theme_images/iconmenumore.gif\" />','" + MenuParent[i].ToString().Split(';')[2] + "','../Tu-Van-Phap-Luat/Default.aspx?MucPhapLuatID=" + MenuParent[i].ToString().Split(';')[0] + "',null,'" + MenuParent[i].ToString().Split(';')[2] + "'," +
                                    Environment.NewLine; 
            }
            ArrayList menuChild = MenuTrai.MenuChild( MenuParent[i].ToString().Split(';')[1]);
            for (int j = 0; j < menuChild.Count; j++)
            {
                checkParent=true;
                sourceMenuTrai += "[ '<img src=\"../File/theme_images/iconmenumore.gif\" />','" + menuChild[j].ToString().Split(';')[1] + "','../Tu-Van-Phap-Luat/Index.aspx?MucPhapLuatID=" + MenuParent[i].ToString().Split(';')[0] + "&MucPhapLuatName=" + MenuParent[i].ToString().Split(';')[1] + "&MucPhapLuatCon=" + menuChild[j].ToString().Split(';')[2] + "',null,'" + menuChild[j].ToString().Split(';')[1] + "'" +
                                        Environment.NewLine + "]," + Environment.NewLine;
            }
            if(checkParent==true)
            {
                sourceMenuTrai = sourceMenuTrai.Substring(0, sourceMenuTrai.Length - 3) + "],";
                checkParent = false;
            }
        }
        sourceMenuTrai = sourceMenuTrai.Substring(0, sourceMenuTrai.Length - 3) + "]]];";
        sourceMenuTrai += "cmDrawNow =function() { cmDraw ('div_JSCook_menu_502e282f1438a', JSCook_menu_502e282f1438a, 'vbr', cmThemeOffice, 'ThemeOffice'); };" +
	"JSCook_menu_502e282f1438a_addEvent( window, \"load\", cmDrawNow, false );"+
"</script>";
        LtlMenuTrai.Text = sourceMenuTrai;
    }



 

    private void FillHTML()
    {
        Control cauhoi = Page.LoadControl("../SlideAnh2.ascx");
        PlaceSlideAnh.Controls.Add(cauhoi);
        ltl5anh.Text = SourceAnhChay.Slide5anhChild();
    }

   
}
